<?php echo $commander->getListCommandsPanel('sa-a-d', ''); ?>
<div class="menu_list">
<input type="hidden" name="action" value="editor_attribute" />
<input type="hidden" name="attribute" value="<?php echo $shop->getCurrentAttributeId(); ?>" />
<input type="hidden" id="del_att_value_id" name="del_att_value_id" value="0" />
<table id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
	<thead class="fields">
        <tr>
            <th class="first center">&nbsp;&nbsp;<?php echo ucfirst($txt->getWord('id')); ?>&nbsp;&nbsp;</th>
            <th><?php echo ucfirst($txt->getWord('choose')); ?></th>
            <th>&nbsp;&nbsp;#&nbsp;&nbsp;</th>
            <th><?php echo ucfirst($txt->getWord('value')); ?></th>
            <th><?php echo ucfirst($txt->getWord('identity').' '.$txt->getWord('postfix')); ?></th>
            <th><?php echo ucfirst($txt->getWord('postfix').' '.$txt->getWord('position')); ?></th>
            <th><?php echo ucfirst($txt->getWord('price').' ('.$txt->getWord('excl').'. '.$txt->getWord('tax').')'); ?></th>
            <th><?php echo ucfirst($txt->getWord('price').' ('.$txt->getWord('inc').'. '.$txt->getWord('tax').')'); ?></th>
            <th><?php echo ucfirst($txt->getWord('order')); ?></th>
            <th><?php echo ucfirst($txt->getWord('visible')); ?></th>
            <th><?php echo ucfirst($txt->getWord('active')); ?></th>
            <th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
        </tr>
    </thead>
    <tbody>
    	<tr class="items">
            <td class="first center"><img 	title="<?php echo ucfirst($txt->getWord('new')); ?>"
                                            class="icon command" 
                                            src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                                            onclick="if(document.getElementById('new_att_value').value != '') { edit_form.submit(); }" /></td>
            <td><input title="<?php echo ucfirst($txt->getWord('all')); ?>" class="select_all" type="checkbox" name="select_all" value="" /></td>
            <th>&nbsp;</th>
            <td><input class="medium" name="new_att_value[]" type="text" value="" maxlength="50" id="new_att_value" /></td>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
            <td>&nbsp;</td>
            <td class="last"></td>
        </tr>
        <?php 
        if($shop->CurrentAttribute->getValues())
		{
			foreach($shop->CurrentAttribute->getValues() as $value)
			{
        ?>
        <tr class="items">
            <td class="first"><?php echo $value->getId(); ?><input type="hidden" name="val_id[]" value="<?php echo $value->getId(); ?>" /></td>
            <td><input class="select_list" type="checkbox" name="selected[]" value="<?php echo $value->getId(); ?>" /></td>
            <td><?php echo ($value->getValueOrder()+1); ?>.</td>
            <td>
                <input class="medium" onchange="this.value=removeInvalidCharsStr(this.value);" onkeydown="this.value=removeInvalidCharsStr(this.value);" onkeyup="this.value=removeInvalidCharsStr(this.value);" name="val_value[]" type="text" value="<?php echo $value->getValue(); ?>" maxlength="99" />
            </td>
            <td>
                <input class="small max_10" name="val_postfix[]" type="text" value="<?php echo $value->getPostfix(); ?>" maxlength="10" />
            </td>
            <td>
                <input class="small max_10 numeric" name="val_postfix_position[]" type="text" value="<?php echo $value->getPostfixPosition(); ?>" maxlength="10" />
            </td>
            <td>
                <input class="max_14 xsmall numeric price val_price_<?php echo $value->getId(); ?>" type="text" name="val_price[]" value="<?php echo $value->getValuePrice(); ?>" id="val_price_<?php echo $value->getId(); ?>" maxlength="14" />
            </td>
            <td>
                <input class="max_14 xsmall numeric price val_price_tax_<?php echo $value->getId(); ?> tax" type="text" name="val_price_tax[]" value="<?php echo $value->getValuePrice(true); ?>" id="val_price_tax_<?php echo $value->getId(); ?>" maxlength="14" />
            </td>
            <td class="center">
				<?php echo $commander->getCommandButton('up', $value->getId()); ?>
                <?php echo $commander->getCommandButton('down', $value->getId()); ?>
            </td>
            <td class="center">
				<?php echo $commander->getVisibleFieldsObject($value); ?>
                <input type="hidden" name="val_visible[]" value="<?php echo $value->getVisible(); ?>" />
            </td>
            <td>
				<?php echo $commander->getActivationFieldsObject($value); ?>
                <input type="hidden" name="val_active[]" value="<?php echo $value->getActive(); ?>" />
            </td>
            <td class="last center">
            	<img title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('value')); ?>" class="icon command delete_v" src="<?php echo SYSICONS_URL; ?>delete_16.gif" onclick="deleteDialog(<?php echo $value->getId(); ?>);" />
                
                <script type="text/javascript">
				$('input.val_price_tax_<?php echo $value->getId(); ?>').change(function() 
				{
					var value = 0;
					value = Math.round(eval($(this).val().replace(/\,/gi, ".").replace(/[^\d\.]/gi, "") * <?php echo (1/$value->getTaxValue()); ?>) * 100) / 100;
					$('input.val_price_<?php echo $value->getId(); ?>').val(value);
				});
				$('input.val_price_<?php echo $value->getId(); ?>').change(function() 
				{
					var value = 0;
					value = Math.round(eval($(this).val().replace(/\,/gi, ".").replace(/[^\d\.]/gi, "") * <?php echo ($value->getTaxValue()); ?>) * 100) / 100;
					$('input.val_price_tax_<?php echo $value->getId(); ?>').val(value);
				});
				</script>
            </td>
        </tr>
        <?php
        	}
		}
        ?>
	</tbody>
</table>
</div>
<script type="text/javascript">
function deleteDialog(productId)
{
	jQuery('#delete_dialog').dialog('open');
	jQuery('#delete_dialog').dialog({
		bgiframe: true,
		resizable: false,
		height:140,
		modal: true,
		overlay: 
		{
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: 
		{
			'<?php echo ucfirst($txt->getWord('no')); ?>': function() 
			{
				jQuery(this).dialog('close');
			},
			'<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('attribute').' '.$txt->getWord('value')); ?>': function() 
			{
				jQuery('#del_att_value_id').val(productId);
				jQuery(this).dialog('close');
				jQuery('#edit_form').submit();
			}
		}
	});
}
</script>
<div id="delete_dialog" title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('attribute')); ?>?" style="display:none; text-align:left;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo ucfirst($txt->getWord('sure_you_want_to_delete')); ?></p>
</div>